﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public abstract class Enemy : Character {
    protected EnemyFSMSystem m_fsmSystem;
    public Enemy()
    {
        MakeFSM();
    }
    private void MakeFSM()
    {
        m_fsmSystem = new EnemyFSMSystem();

        EnemyChaseState chaseState = new EnemyChaseState(m_fsmSystem, this);
        chaseState.AddTransition(EnemyTransition.CanAttack, EnemyStateID.Attack);

        EnemyAttackState attackState = new EnemyAttackState(m_fsmSystem, this);
        attackState.AddTransition(EnemyTransition.LostSoldier, EnemyStateID.Chase);

        m_fsmSystem.AddState(chaseState, attackState);

    }
    public override void UpdateFSMAI(List<Character> targets)
    {
        m_fsmSystem.currentState.Reason(targets);
        m_fsmSystem.currentState.Act(targets);
    }



    public override void UnderAttack(float dmg)
    {
        base.UnderAttack(dmg);
        PlayEffect(m_attr.EffectName);
        if (m_attr.CurrentHP <= 0)
        {
            Killed();
        }
    }
   
}
